import { http } from '@/utils/httpRequest'
import { stringify } from 'qs'

export default {
    // 按照文件夹的方式来定义模块的名称
    namespaced: true,
    state: {
        // 所有的部门数据, 因为部门比较少，所以一次性查全部, 这是表格展示用
        depts: {},
        daimovie: {},
        Pagingdata:{},
        queryData:{
            limit: 12,
            offset: 0,
            total:0
        },
    },
    mutations: {
            setPageEmployees(state, depts) {
                state.depts = depts
            },
            setPageEmployee(state, depts) {
                state.depts = depts
            },

            // 设置总的数据量
            setTotal(state, total) {
                state.queryData.total = total
            },
            // 设置currentPage, 以服务端计算为准
            setCurrentPage(state, offset) {
                state.queryData.offset = offset
            },
            setPageSize(state,limit){
                state.queryData.limit = limit
        },
        setDaiMovie(state, daimovie) {
                state.daimovie = daimovie
        },
        
        },
    actions: {
        getPageData({ commit,state }) {
            http.get(`/api/mmdb/movie/v2/list/hot.json?${stringify(state.queryData)}&ct=广州`).then(res => {
                // commit('setPageEmployees', res.data.data.result)  // 每页的数据
                console.log(res.data.data)
                commit('setPageEmployees', res.data.data.hot)
                commit('setTotal', res.data.data.paging.total)
                commit('setCurrentPage', res.data.data.paging.offset)
                commit('setCurrentPage', res.data.data.paging.limit)


            })

        },
       async getPageDat({commit,state}){
           await http.get(`/api/mmdb/movie/v2/list/hot.json?${stringify(state.queryData)}&ct=广州`).then(res => {
                console.log(res.data.data.hot)
                commit('setPageEmployee',res.data.data.hot)
                // this.depts.concat(res.data.data.hot)
                // this.depts = this.depts.post(res.data.data.hot)
            })
        },
          async  getDaiMovie({ commit }) {
             await   http.get('/api/mmdb/movie/v2/list/rt/order/coming.json?ci=20&limit=10').then(res => {
                    console.log('获取数据',res.data.data);
                    commit('setDaiMovie', res.data.data.coming)
                })
            },
       
    }
}